<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>一个多用户博客后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> <link href="../public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="../public/css/plugins/iCheck/custom.css" rel="stylesheet">

    <link href="../public/css/animate.css" rel="stylesheet">
    <link href="../public/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
      <div class="row">
          <div class="ibox float-e-margins">
              <div class="ibox-title">
                  <h5>用户管理</h5>
                  <div class="ibox-tools">
                      <a class="collapse-link">
                          <i class="fa fa-chevron-up"></i>
                      </a>


                  </div>
              </div>
              <div class="ibox-content">
                  <a class="btn btn-primary" href="/admin/user-add">新增用户</a>
                  <a class="btn btn-primary" href="/admin/user-add">查看权限</a>
                  
                  <form action="" method="POST" role="form">
                      <div class="input-group col-sm-6">
                          <input type="text" class="form-control" placeholder="搜索用户名称"> <span class="input-group-btn"> <button type="button" class="btn btn-primary">搜索
                          </button> </span>
                      </div>
                  </form>
                  

                  <table class="table table-bordered">
                      <thead>
                          <tr>
                              <th>ID</th>
                              <th>用户级别</th>
                              <th>名称</th>
                              <th>别名</th>
                              <th>文章总数</th>
                              <th>操作</th>
                          </tr>
                      </thead>
                      <tbody>
                        {{each doc}}
                          <tr>
                              <td>{{$index}}</td>
                              <td>{{$value.level | admin}}</td>
                              <td>{{$value.name}}</td>
                              <td>{{$value.nickName}}</td>
                              <td>{{$value.artcount}}</td>
         
                              <td>
                                <a href="javascript:void(0)" onclick="modelShow('{{$value.name}}')"><i class="fa fa-edit text-navy"></i></a>
                                <a href="/admin/delete/{{$value.name}}"><i class="fa fa-remove text-navy"></i></a>
                              </td>
                          </tr>
                          {{/each}}
                          
                      </tbody>
                  </table>
              </div>
          </div>
      </div>
    </div>


    <!--弹窗-->
<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content animated bounceInRight">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span> </button>
          <h4 class="modal-title">用户资料</h4>
          <small class="font-bold">修改用户资料</small> </div>
        <div class="modal-body">
          <form id="edit-form" class="form-horizontal" method="POST">
            <div class="form-group">
                <label class="col-sm-2 control-label">用户级别:
                </label>
                <div class="col-sm-10" id="level">
                    <label class="radio-inline i-checks">
                        <input type="radio" value="0" name="level" >管理员</label>
                    <label class="radio-inline i-checks">
                            <input type="radio" value="1" name="level">网站编辑</label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="2" name="level" >作者</label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="3" name="level">游客</label>  
                  
                </div>
              </div>

              <div class="hr-line-dashed"></div>
              <div class="form-group">
                <label class="col-sm-2 control-label">用戶状态:</label>

                <div class="col-sm-10" id="power">
                    <label class="radio-inline i-checks" >
                        <input type="radio" value="0" name="power" >正常</label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="1" name="power" >审核</label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="2" name="power">禁止</label>
                </div>
              </div>
              <div class="hr-line-dashed"></div>
              <div class="form-group">
                <label class="col-sm-2 control-label">名称:</label>
                <div class="col-sm-10">
                  <input type="text" class="form-control" name="name" disabled id="name">
                </div>
              </div>
              <div class="hr-line-dashed"></div>
              <div class="form-group">
                <label class="col-sm-2 control-label">密码:</label>
                <div class="col-sm-10">
                  <input type="password" class="form-control" name="password">
                </div>
              </div>

                <div class="hr-line-dashed"></div>
              <div class="form-group">
                <label class="col-sm-2 control-label">昵称:</label>

                <div class="col-sm-10">
                  <input type="text" class="form-control" name="nickName" id="nickName">
                </div>
              </div>
              <div class="hr-line-dashed"></div>
              <div class="form-group">
                  <label class="col-sm-2 control-label">邮箱:</label>
  
                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="email" id="email">
                  </div>
                </div>
                <div class="hr-line-dashed"></div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" onClick="sub()">保存</button>
        </div>
      </div>
    </div>
  </div>
  






     <!-- 全局js -->
     <script src="../public/js/jquery.min.js?v=2.1.4"></script>
     <script src="../public/js/bootstrap.min.js?v=3.3.6"></script>
     <script src="../public/js/plugins/layer/layer.min.js"></script>
 
     <!-- 自定义js -->
     <script src="../public/js/content.js"></script>
      <!-- iCheck -->
  <script src="../public/js/plugins/iCheck/icheck.min.js"></script>
  <script>
    $(document).ready(function () {
      $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
      });
    });
  </script>


    <script>
function modelShow(id){
    $('#edit-form').attr('action','/admin/edit-user/'+id)
    $.ajax({
        url:'/admin/getuse/'+id,
        method:'get',
        success(data){
            $('#level input').each(function(){
                $(this).parent().removeClass('checked')
                if($(this).val()==data.level){
                    $(this).prop("checked", true)
                    $(this).parent().addClass('checked')
                }
            })
            $('#power input').each(function(){
                $(this).parent().removeClass('checked')
                if($(this).val()==data.power){
                    $(this).prop("checked", true)
                    $(this).parent().addClass('checked')
                }
            })
            $('#name').val(data.name)
            $('#nickName').val(data.nickName)
            $('#email').val(data.email)
       }
    })
  $('#myModal').modal('show')
}

function sub(){
  $('#edit-form').submit()
}
    </script>


    


</body>

</html>
